home *** CD-ROM | disk | FTP | other *** search
/ Apple Reference & Presen…tion Library 2 (Reseller) / Apple R&P Lib Reseller v2.0.iso / 3-Demos / HyperCard Demos / HyperCard In Education / HyperTree / stack_-1.xml < prev    next >
Encoding:
Extensible Markup Language  |  1989-07-14  |  8.0 KB  |  16 lines

  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
  3. <stack>
  4.     <name>in</name>
  5.     <id>-1</id>
  6.     <cardCount>2</cardCount>
  7.     <cardID>3233</cardID>
  8.     <listID>2830</listID>
  9.     <cantModify><false /></cantModify>
  10.     <cantDelete><false /></cantDelete>
  11.     <cantAbort><false /></cantAbort>
  12.     <cardSize>
  13.         <width>512</width>
  14.         <height>342</height>
  15.     </cardSize>
  16.     <script>on domenu menu -- Script added by Animatrix 7/14/89
  17. global RPstackname,RPcardname
  18. if menu is in "Home,Quit HyperCard" then
  19. if RPstackname is not empty then
  20. answer "This will return to "&RPStackname&"."
  21. set cursor to watch
  22. lock screen
  23. go card RPcardname of stack RPstackname
  24. unlock screen with dissolve
  25. exit domenu
  26. else pass domenu -- if RPstackname is empty
  27. else
  28. pass domenu -- if menu is not in home or quit
  29. end if
  30. end domenu
  31.  
  32. on openStack
  33. defineStruct
  34. set the lineSize to 1
  35. set the pattern to 1
  36. show message at 22,300
  37. end openStack
  38.  
  39. on closeStack
  40. put empty into message
  41. set the pattern to 12
  42. end closeStack
  43.  
  44. on openCard
  45. global rootNode, searchPath, pathLength
  46. if the number of card fields > 0 then
  47. put the id of card field 1 into rootNode
  48. else
  49. put 0 into rootNode
  50. end if
  51. put empty into searchPath
  52. put 0 into pathLength
  53. walkTree
  54. end openCard
  55.  
  56. on deleteCard
  57. global searchPath, pathLength
  58. put empty into searchPath
  59. put 0 into pathLength
  60. end deleteCard
  61.  
  62. on closeCard
  63. undoPlot
  64. put empty into field treeList
  65. end closeCard
  66.  
  67. on defineStruct
  68. global rootRect, rootLoc, hSpacing, vSpacing, rootLevel
  69. put "241,148,271,163" into rootRect
  70. put "256,155" into rootLoc
  71. put "16,32,64,128" into hSpacing
  72. put "30,30,30,30" into vSpacing
  73. put 4 into rootLevel
  74. end defineStruct
  75.  
  76. on eraseTree
  77. global rootNode, seachPath, pathLength
  78. choose select tool
  79. drag from 0,0 to 512,342
  80. doMenu "Clear Picture"
  81. choose field tool
  82. repeat with i = the number of card fields down to 1
  83. click at the loc of card field i
  84. doMenu "Clear Field"
  85. end repeat
  86. put 0 into rootNode
  87. put empty into searchPath
  88. put 0 into pathLength
  89. choose browse tool
  90. end eraseTree
  91.  
  92. on initPlot targetNode
  93. global searchPath, pathLength
  94. undoPlot
  95. put targetNode into line 1 of searchPath
  96. put the loc of card field id targetNode into¬¨
  97. line 2 of searchPath
  98. put 2 into pathLength
  99. set the style of card field id targetNode to shadow
  100. set the lineSize to 2
  101. choose line tool
  102. end initPlot
  103.  
  104. on termPlot
  105. set the lineSize to 1
  106. choose browse tool
  107. end termPlot
  108.  
  109. on pathPlot targetNode
  110. global searchPath, pathLength
  111. if targetNode ‚↠0 then
  112. add 1 to pathLength
  113. put targetNode into line pathLength of searchPath
  114. add 1 to pathLength
  115. put the loc of card field id targetNode into¬¨
  116. line pathLength of searchPath
  117. set the style of card field id targetNode to shadow
  118. drag from line pathLength - 2 of searchPath to¬¨
  119. line pathLength of searchPath
  120. end if
  121. end pathPlot
  122.  
  123. on undoPlot
  124. global searchPath, pathLength
  125. if pathLength > 0 then
  126. choose line tool
  127. put line 1 of searchPath into targetNode
  128. set the style of card field id targetNode to rectangle
  129. put line 2 of searchPath into parentLoc
  130. put 3 into pathIndex
  131. repeat while pathIndex < pathLength
  132. put line pathIndex of searchPath into targetNode
  133. add 1 to pathIndex
  134. get line pathIndex of searchPath
  135. add 1 to pathIndex
  136. set the style of card field id targetNode to rectangle
  137. set the lineSize to 2
  138. drag from parentLoc to it with optionKey
  139. set the lineSize to 1
  140. drag from parentLoc to it
  141. put it into parentLoc
  142. end repeat
  143. put empty into searchPath
  144. put 0 into pathLength
  145. choose browse tool
  146. end if
  147. end undoPlot
  148.  
  149. function searchTree key
  150. global rootNode, rootLevel
  151. global parentSide, parentNode, parentLevel, targetNode
  152. put 0 into parentSide
  153. put 0 into parentNode
  154. put rootLevel + 1 into parentLevel
  155. if rootNode = 0 then
  156. put 0 into targetNode
  157. return "missing"
  158. else
  159. initPlot rootNode
  160. if key = line 1 of card field id rootNode then
  161. put rootNode into targetNode
  162. return "found"
  163. end if
  164. end if
  165. put rootNode into parentNode
  166. put rootLevel into parentLevel
  167. put 0 into targetNode
  168. repeat while true
  169. get line 1 of card field id parentNode
  170. if key < it then
  171. put 2 into parentSide
  172. get line 2 of card field id parentNode
  173. if it ‚↠0 then
  174. pathPlot it
  175. if key = line 1 of card field id it then
  176. put it into targetNode
  177. return "found"
  178. else
  179. put it into parentNode
  180. subtract 1 from parentLevel
  181. end if
  182. else
  183. return "missing"
  184. end if
  185. else
  186. if key > it then
  187. put 3 into parentSide
  188. get line 3 of card field id parentNode
  189. if it ‚↠0 then
  190. pathPlot it
  191. if key = line 1 of card field id it then
  192. put it into targetNode
  193. return "found"
  194. else
  195. put it into parentNode
  196. subtract 1 from parentLevel
  197. end if
  198. else
  199. return "missing"
  200. end if
  201. end if
  202. end if
  203. end repeat
  204. end searchTree
  205.  
  206. function newNode nodeLoc
  207. global rootRect
  208. choose field tool
  209. doMenu "New Field"
  210. get the number of card fields
  211. get the id of card field it
  212. set the rect of card field id it to rootRect
  213. set the loc of card field id it to nodeLoc
  214. set the style of card field id it to rectangle
  215. set the textFont of card field id it to geneva
  216. set the textSize of card field id it to 9
  217. set the textAlign of card field id it to center
  218. set the lockText of card field id it to true
  219. put 0 into line 2 of card field id it
  220. put 0 into line 3 of card field id it
  221. return it
  222. end newNode
  223.  
  224. function getNodeLoc parentSide, parentNode, parentLevel
  225. global rootLoc, hSpacing, vSpacing
  226. if parentNode = 0 then
  227. return rootLoc
  228. else
  229. put the loc of card field id parentNode into nodeLoc
  230. get item parentLevel of vSpacing
  231. add it to item 2 of nodeLoc
  232. get item parentLevel of hSpacing
  233. if parentSide = 2 then
  234. subtract it from item 1 of nodeLoc
  235. else
  236. add it to item 1 of nodeLoc
  237. end if
  238. return nodeLoc
  239. end if
  240. end getNodeLoc
  241.  
  242. function makeNode parentSide, parentNode, parentLevel
  243. global rootLoc
  244. if parentNode = 0 then
  245. get newNode( rootLoc )
  246. initPlot it
  247. return it
  248. else
  249. put getNodeLoc( parentSide, parentNode, parentLevel ) into nodeLoc
  250. get newNode( nodeLoc )
  251. put it into line parentSide of card field id parentNode
  252. choose line tool
  253. pathPlot it
  254. return it
  255. end if
  256. end makeNode
  257.  
  258. function insertNode key
  259. global rootNode, parentSide, parentNode, parentLevel
  260. get searchTree( key )
  261. if it = "found" then
  262. termPlot
  263. return "duplicate"
  264. end if
  265. if parentLevel = 0 then
  266. termPlot
  267. return "full"
  268. end if
  269. put makeNode( parentSide, parentNode, parentLevel ) into theNode
  270. put key into line 1 of card field id theNode
  271. if parentNode = 0 then put theNode into rootNode
  272. termPlot
  273. return "inserted"
  274. end insertNode
  275.  
  276. on moveSubTree parentSide, parentNode, parentLevel, nextNode
  277. if nextNode ‚↠0 then
  278. put the loc of card field id nextNode into oldLoc
  279. put getNodeLoc( parentSide, parentNode, parentLevel ) into newLoc
  280. set the loc of card field id nextNode to newLoc
  281. get line 2 of card field id nextNode
  282. if it ‚↠0 then
  283. drag from oldLoc to the loc of card field id it with optionKey
  284. moveSubTree 2, nextNode, parentLevel - 1, it
  285. end if
  286. get line 3 of card field id nextNode
  287. if it ‚↠0 then
  288. drag from oldLoc to the loc of card field id it with optionKey
  289. moveSubTree 3, nextNode, parentLevel - 1, it
  290. end if
  291. if parentNode ‚↠0 then
  292. drag from the loc of card field id parentNode to newLoc
  293. end if
  294. end if
  295. end moveSubTree
  296.  
  297. function removeNode parentSide, parentNode, parentLevel, targetNode
  298. global rootNode
  299. put line 1 of card field id targetNode into key
  300. if line 2 of card field id targetNode = 0 then
  301. put line 3 of card field id targetNode into nextNode
  302. else
  303. put line 2 of card field id targetNode into nextNode
  304. end if
  305. choose line tool
  306. if parentNode ‚↠0 then
  307. drag from the loc of card field id parentNode to¬¨
  308. the loc of card field id targetNode with optionKey
  309. set the lineSize to 1
  310. end if
  311. if nextNode ‚↠0 then
  312. drag from the loc of card field id targetNode to¬¨
  313. the loc of card field id nextNode with optionKey
  314. end if
  315. choose field tool
  316. click at the loc of card field id targetNode
  317. doMenu "Clear Field"
  318. if parentNode ‚↠0 then
  319. put nextNode into line parentSide of card field id parentNode
  320. end if
  321. if targetNode = rootNode then put nextNode into rootNode
  322. choose line tool
  323. moveSubTree parentSide, parentNode, parentLevel, nextNode
  324. return key
  325. end removeNode
  326.  
  327. on findNext
  328. global parentSide, parentNode, parentLevel, targetNode
  329. put "Looking for the successor to node" &&¬¨
  330. line 1 of card field id targetNode into message
  331. put 3 into parentSide
  332. put targetNode into parentNode
  333. subtract 1 fr